package cn.masterj.springcloud.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

/**
 * @author masterJ
 * @create 2020-04-15 21:41
 */

@EnableBinding(Sink.class)
public class ConsumerService {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void receive(Message<String> message){
        System.out.println(serverPort + "接收到的消息：" + message.getPayload());
    }
}
